package com.maixun.lib_business_home.home

import android.content.Context
import com.maixun.lib_business_home.R
import com.maixun.lib_business_home.entity.HomeDataBeen
import com.maixun.lib_business_home.entity.HomeHeadBeen
import com.maixun.lib_comment.recyclerview.BaseAdapter
import com.maixun.lib_comment.recyclerview.ViewHolderImpl

/**
 * @author：Lmoumou
 * @date：2020/10/16
 */
class HomeAdapter(mContext: Context, dataList: MutableList<Any>) :
    BaseAdapter<Any>(mContext, dataList) {
    override fun itemViewType(position: Int): Int {
        return when (dataList[position]) {
            is HomeHeadBeen -> R.layout.home_item_home_title
            is HomeDataBeen.HomeVideoBeen -> R.layout.home_item_home_video
            is HomeDataBeen.HomeLiteratureBeen -> R.layout.home_item_home_literature
            is HomeDataBeen.HomeExpertBeen -> R.layout.home_item_home_expert
            else -> R.layout.home_item_unknown
        }
    }

    override fun bindData(holder: ViewHolderImpl, position: Int) {
        when(val data=dataList[position]){
            is HomeHeadBeen->{
                bindHeadData(holder,data,position)
            }
        }
    }

    private fun bindHeadData(holder: ViewHolderImpl, data: HomeHeadBeen, position: Int) {
        holder.setImageResource(R.id.tvIcon,data.iconResId)
        holder.setText(R.id.tvTitle,data.model)
    }
}